package com.test;

/**
 * Created by HBZ on 2017/5/16.
 */
public class Main {
    public static int div(int a,int b) throws ArithmeticException{
        return a/b;
    }
    public static void main(String [] args)throws ArithmeticException,MyException {
       /* try {
            throw new MyException("faf");

        } catch (Exception e) {
            e.printStackTrace();
        }*/
        String string="";
        try {
            string=aa(1);
        } catch (MyException e) {
            e.printStackTrace();
        } catch (MyException2 myException2) {
            myException2.printStackTrace();
            //再次抛出异常
            MyException t=new MyException("a");
            t.initCause(myException2);
            System.out.println(t.getCause());
            throw t;
        }

        System.out.println("结束----------");
    }

    public static String aa(int i)throws MyException,MyException2 {
        if(i==0){
            throw new MyException("MyException");
        }
        else if(i==1){
            throw new MyException2("MyException2");
        }
//        try {
//
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

        return "a";
    }
}
